package mashibing.a_xsb;

import java.util.Arrays;

/**
 * @author yujiafan
 * @version 1.0.0
 * @create 2022-12-22
 */
public class NewClassDay2 {

    public static void main(String[] args) {
        double count = 100000;
        int count1 = 0;
        for (int i = 0; i < count; i++) {
            double min = Math.max(Math.random(), Math.random());
            if (min <= 0.5) {
                count1++;
            }
        }
        System.out.println("==============");
        int[] arr = new int[8];
        for (int i = 0; i < count; i++) {
            int index = f4();
            arr[index]++;
        }

        System.out.println(Arrays.toString(arr));

    }

    // 1-5
    public static int f1() {
        return (int) (Math.random() * 5) + 1;
    }

    // 1-2:0 3 4-5:1    01发生器
    public static int f2() {
        int ans = 0;
        do {
            ans = f1();
        } while (ans == 3);
        return ans < 3 ? 0 : 1;
    }

    // 返回0-7
    public static int f3(){
        return (f2() << 2) + (f2() << 1) + f2();
    }
    public static int f4(){
        int ans = 0;
        do {
            ans = f3();
        } while (ans == 0);
        return ans;
    }
}
